package freaks.terah.model;

import java.util.ArrayList;

import javax.swing.DefaultListModel;

public class RessourceModel extends DefaultListModel<Ressource> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5325711140538655112L;
	ArrayList<Integer> filteredList = null;
	
	@Override
	public int getSize()
	{
		if (filteredList != null)
			return filteredList.size();
		
		return super.size();
	}
	
	@Override
	public Ressource getElementAt(int arg0) {
		if (filteredList != null)
			return super.getElementAt(filteredList.get(arg0));
		
		return super.getElementAt(arg0);
	}
	
	public void setFilter(ArrayList<Integer> filter)
	{
		filteredList = filter;	
	}
	
	public void removeFilter()
	{
		filteredList = null;
	}
}
